package com.yazi.mxz.server.controller;

import java.util.List;

import javax.annotation.Resource;

import com.fasterxml.jackson.annotation.JsonView;
import com.yazi.mxz.common.entity.beans.Store;
import com.yazi.mxz.common.service.StoreService;
import com.yazi.mxz.server.response.StoreListResponse;
import com.yazi.mxz.server.response.view.BaseView;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller("storeController")
@RequestMapping("/store")
public class StoreController extends BaseController {
	private static Logger log = LoggerFactory.getLogger(StoreController.class);

	@Resource
	StoreService storeService;

	@RequestMapping("/list")
	@ResponseBody
	@JsonView(BaseView.class)
	public StoreListResponse list() {
		log.debug("客户端请求 -> 获取店铺列表");
		StoreListResponse res = new StoreListResponse();
		try {
			List<Store> storeList = storeService.search(null, null, null);
			res.setSuccessData(storeList);
			res.setOk();
		} catch (Exception e) {
			log.error("获取店铺列表异常:", e);
			res.setErrorMessage("操作失败,请联系管理员");
		}
		return res;
	}
}
